package com.luyu.rabbitmqdemo.mq.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @author luYu
 */
@Slf4j
@Component
public class ConfirmBack implements RabbitTemplate.ConfirmCallback {


    /**
     * Confirmation callback.
     *
     * @param correlationData correlation data for the callback.
     * @param ack             true for ack, false for nack
     * @param cause           An optional cause, for nack, when available, otherwise null.
     */
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            log.info("ConfirmBack 消息成功发送到exchange");
        } else {
            log.error("ConfirmBack 消息发送exchange失败:" + cause);
        }

    }
}
